unit fmMain;

interface

uses
  ShellAPI,Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ExtCtrls, Menus,FolderView,FolderPanel, StdCtrls;

type
  TForm1 = class(TForm)
    mmMain: TMainMenu;
    pnl1: TPanel;
    File1: TMenuItem;
    ChangeDir1: TMenuItem;
    GetDir1: TMenuItem;
    opLevel1: TMenuItem;
    Up1: TMenuItem;
    Downdir1: TMenuItem;
    ChangeDriver1: TMenuItem;
    ShellExecute1: TMenuItem;
    Search1: TMenuItem;
    System1: TMenuItem;
    DosPrompt1: TMenuItem;
    Copy1: TMenuItem;
    Move1: TMenuItem;
    Delete1: TMenuItem;
    RunCommand1: TMenuItem;
    OpenFolder1: TMenuItem;
    Label1: TMenuItem;
    New1: TMenuItem;
    Close1: TMenuItem;
    SwitchLeftRight1: TMenuItem;
    ViewFolder1: TMenuItem;
    togglePanel1: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure Up1Click(Sender: TObject);
    procedure DosPrompt1Click(Sender: TObject);
    procedure togglePanel1Click(Sender: TObject);
    procedure ShellExecute1Click(Sender: TObject);
    procedure opLevel1Click(Sender: TObject);
    procedure ChangeDir1Click(Sender: TObject);
    procedure GetDir1Click(Sender: TObject);
    procedure Downdir1Click(Sender: TObject);
    procedure OpenFolder1Click(Sender: TObject);
    procedure ChangeDriver1Click(Sender: TObject);
    procedure Copy1Click(Sender: TObject);
    procedure Move1Click(Sender: TObject);
    procedure Delete1Click(Sender: TObject);
  private
    FfpCurr: TFolderPanel;
    function GetCurrFolderPanel: TFolderPanel;
  private
    { Private declarations }
    spSplit : TSplitter;
    fpLeft,fpRight : TFolderPanel;
    property fpCurr : TFolderPanel read GetCurrFolderPanel write FfpCurr ;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
const InitDir = 'c:\';
procedure TForm1.FormCreate(Sender: TObject);
begin
  spSplit := TSplitter.Create(Self);
  fpLeft := TFolderPanel.Create(self);
  fpRight := TFolderPanel.Create(Self);
  fpLeft.PeerFolderPanel := fpRight ;
  fpRight.PeerFolderPanel := fpLeft ;
  fpLeft.Align := alLeft ;
  fpRight.Align := alClient ;

  InsertControl(spSplit);
  InsertControl(fpLeft);
  InsertControl(fpRight);
  fpLeft.Width := Width div 2 ;
  fpLeft.CurrDir := InitDir;
  fpRight.CurrDir := InitDir;
  togglePanel1Click(Self);
  fpCurr := fpLeft ;
end;

procedure TForm1.Up1Click(Sender: TObject);
begin
  fpCurr.UpDir();
end;

procedure TForm1.DosPrompt1Click(Sender: TObject);
begin
  fpCurr.DosPrompt ;
end;

procedure TForm1.togglePanel1Click(Sender: TObject);
begin
  if fpLeft.Focused then begin
    fpRight.Focused :=true ;
  end
  else   begin
    fpLeft.Focused := True ;
  end;
end;

procedure TForm1.ShellExecute1Click(Sender: TObject);
begin
 fpCurr.Execute;
end;

procedure TForm1.opLevel1Click(Sender: TObject);
begin
  fpCurr.Root;
end;

procedure TForm1.ChangeDir1Click(Sender: TObject);
begin
  fpCurr.CurrDir := ('d:\lcjun');
end;

procedure TForm1.GetDir1Click(Sender: TObject);
begin
  fpCurr.CopyFilePathToClp;
end;

procedure TForm1.Downdir1Click(Sender: TObject);
begin
  fpCurr.DownDir;
end;

procedure TForm1.OpenFolder1Click(Sender: TObject);
begin
  fpCurr.OpenExplorer ;
end;

procedure TForm1.ChangeDriver1Click(Sender: TObject);
begin
  fpCurr.ListDrives;
end;

procedure TForm1.Copy1Click(Sender: TObject);
begin
  fpCurr.DoCopy;
end;

procedure TForm1.Move1Click(Sender: TObject);
begin
  fpCurr.DoMove;
end;

procedure TForm1.Delete1Click(Sender: TObject);
begin
  fpCurr.DoDelete;
end;

function TForm1.GetCurrFolderPanel: TFolderPanel;
begin
  if fpLeft.Focused then
    Result := fpLeft
  else
    Result := fpRight ;
end;

end.
